package editor.manager;

import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

import editor.Context;
import editor.project.ProjectFile;
import editor.tester.JWalkRunner;

/**
 * Testing Manager
 * 
 * @author Mark Dessain
 */
@SuppressWarnings("serial")
public class TestingManager extends JTabbedPane
{
	/**
	 * 
	 */
	public TestingManager()
	{
		this.add("No Results", new JLabel("No Results"));
	}
	
	/**
	 * @param file the class file which is to be tested
	 */
	public void run(ProjectFile file)
	{
		Context.setMainProject(file.getProject());
		
		Context.getSideBarManager().questionMode();
		WorkSpaceManager.consoleManager.questionMode();
		WorkSpaceManager.textAreaManager.add(file, false);
		
		// Starts JWalk
		Thread jwalkRunner = new Thread(new JWalkRunner(file), "jwalkrunner");
		jwalkRunner.start();

	}
	
	/**
	 * @param title for the new tab
	 * @param content for the new tab
	 */
	public void addOutput(String title, String content)
	{
		JTextArea testPane = new JTextArea();
		testPane.setText(content);
        JScrollPane testScroll = new JScrollPane(testPane);
                
        addTab(title, testScroll);
	}
	
}
